﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using WLYT.Admin.WebApi.Models;
using WLYT.Application.Interfaces;
using WLYT.Domain.Model;

namespace WLYT.Admin.WebApi.Controllers
{
    [System.Web.Http.Description.ApiExplorerSettings(IgnoreApi = true)]
    public class LogController : BaseController
    {
        private readonly ILogRecordService LogRecordService;
        private readonly IDataBaseLogService DataBaseLogService;
        private readonly IAgvLogService AgvLogService;

        public LogController(ILogRecordService logRecordService, IDataBaseLogService dataBaseLogService, IAgvLogService agvLogService)
        {
            LogRecordService = logRecordService;
            DataBaseLogService = dataBaseLogService;
            AgvLogService = agvLogService;
        }

        [HttpGet]
        [Route("api/LogRecord/GetData")]
        public async Task<Table<LogRecord>> GetLogRecords(DateTime? time, string url, string content, int pageSize, int pageIndex)
        {
            var response = await LogRecordService.GetModelsByPageAsync(time, url, content, pageSize, pageIndex);
            return new Table<LogRecord>(response.Item1, response.Item2);
        }

        [HttpGet]
        [Route("api/DataBaseLog/GetData")]
        public async Task<Table<DataBaseLog>> GetDataBaseLogs(DateTime? time, string search, int pageSize, int pageIndex)
        {
            var response = await DataBaseLogService.GetModelsByPageAsync(time, search, pageSize, pageIndex);
            return new Table<DataBaseLog>(response.Item1, response.Item2);
        }

        [HttpGet]
        [Route("api/AgvLog/GetData")]
        public async Task<Table<AgvLog>> GetAgvLogs(DateTime? time, string search, int pageSize, int pageIndex)
        {
            var response = await AgvLogService.GetModelsByPageAsync(time, search, pageSize, pageIndex);
            return new Table<AgvLog>(response.Item1, response.Item2);
        }
    }
}